#include <iostream>
#include <cstdio>
using namespace std;

int main() {
    int year, month, day, ans;
    cin >> year >> month >> day;

    int a[13] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
    ans = a[month - 1] + day;
    if (month > 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
        ++ans;
    cout << ans << endl;
    return 0;
}